﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace DARE
{
    [AttrTypeDependentSerializable(typeof(CPointEmitter))]
    public class CPointEmitter: AEmitter
    {
        #region ctor

        public CPointEmitter(string name)
            :base(name)
        {

        }

        #endregion

        #region methods

        public override AEmitter Clone()
        {
            CPointEmitter pe = new CPointEmitter(Name);
            pe.EmissionInterval = EmissionInterval;
            pe.EmitPerEmission = EmitPerEmission;
            pe.MaxParticlesSimultaneous = MaxParticlesSimultaneous;
            pe.ReferenceParticle = ReferenceParticle;
            return pe;
        }

        public override void GetParametersFromEmitter(IParticle particle)
        {
            particle.Position = m_node.Position;
            float xm_rand = CDare.Instance.Random.Next(2000) / 1000.0f;
            float ym_rand = CDare.Instance.Random.Next(2000) / 1000.0f;
            float zm_rand = CDare.Instance.Random.Next(2000) / 1000.0f;
            Vector3 dir = new Vector3(xm_rand - 1, ym_rand - 1, zm_rand - 1);
            dir.Normalize();

            particle.Velocities = Velocities * dir;
        }
        
        #endregion
    }
}
